const STATUS = require('../constants/error.code')


module.exports = (err, ctx) => {
  let status = 500
  switch (err.code) {
    case 10001:
      status = STATUS.BAD_REQUEST
      break
    case 10002:
      status = STATUS.CONFLICT
      break
    case 10003:
      status = STATUS.CONFLICT
      break
    case 10004:
      status = STATUS.CONFLICT
      break
    case 10005:
      status = STATUS.FORBIDDEN
      break
    default:
      status = 500
  }

  ctx.status = status
  ctx.body = err
}
